package com.roy.base;

import dev.langchain4j.data.message.AiMessage;
import dev.langchain4j.data.message.UserMessage;
import dev.langchain4j.model.openai.OpenAiChatModel;
import dev.langchain4j.model.output.Response;

/**
 * @author 山顶洞人郑某
 * @className HelloWord.java
 * @date 2025 03 31
 */
public class HelloWord {
    //实现上下文相关的聊天
    public static void main(String[] args) {
        OpenAiChatModel model = OpenAiChatModel.builder()
                .apiKey("demo")
                .modelName("gpt-4o-mini")
                .build();
        UserMessage userMessage = UserMessage.from("你是谁");
        Response<AiMessage> response = model.generate(userMessage);
        System.out.println(response.content().text());
        UserMessage userMessage2 = UserMessage.from("重复一下");
        Response<AiMessage> response1 = model.generate(userMessage, response.content(), userMessage2);
        System.out.println(response1.content().text());
    }
}
